#!/usr/bin/python
'''
Changes AXT to gff.
'''
import sys
import os

# Parameters.
in_file = sys.argv[1]

# Loop over in file.
fin = open(in_file,"rb")
for line in fin:
	# skip sequence lines.
	if line.count(">") == 0: continue
	
	# Tokenize.
	tmp = line.strip().split()
	seqname = tmp[4].replace(">","")
	source = "LASTZ"
	feature = tmp[1].replace(">","")
	start = tmp[5]
	end = tmp[6]
	score = "."
	strand = tmp[7]
	frame = "."
	group = tmp[1].replace(">","")
	
	print "%s\t%s\tEXON\t%s\t%s\t%s\t%s\t%s\t%s" % (feature, source, start, end, score, strand, frame, seqname)
	
# seqname - The name of the sequence. Must be a chromosome or scaffold.
# source - The program that generated this feature.
# feature - The name of this type of feature. Some examples of standard feature types are "CDS", "start_codon", "stop_codon", and "exon".
# start - The starting position of the feature in the sequence. The first base is numbered 1.
# end - The ending position of the feature (inclusive).
# score - A score between 0 and 1000. If the track line useScore attribute is set to 1 for this annotation data set, the score value will determine the level of gray in which this feature is displayed (higher numbers = darker gray). If there is no score value, enter ".".
# strand - Valid entries include '+', '-', or '.' (for don't know/don't care).
# frame - If the feature is a coding exon, frame should be a number between 0-2 that represents the reading frame of the first base. If the feature is not a coding exon, the value should be '.'.
# group - All lines with the same group are linked together into a single item. 
#['0', '>KERV.F3_1rc_AC171384.2', '1', '185', '>Scaffold_104355_ABQO010863850.1_ABQO011198325.1', '3049', '3242', '+', '9088']

fin.close()
